package org.example.listener;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
//监听器
// 主要作用：监听应用上下文，在启动服务器的过程中需要执行业务逻辑，通过监听器完成
public class MyListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        System.out.println("执行监听器");
        System.out.println("将取得mysql的数据，保存到redis里面");
        /*
        这个context叫做应用上下文
         */
 /*       ApplicationContext context = contextRefreshedEvent.getApplicationContext();
        Xxx xxx=context.getBean(xxx)*/

    }
}
